public class num_quantity {
    public static int isNumeric(String str){
        byte[] array1 = str.getBytes();//将字符串转换为字符数组
        int count = 0;//设置一个计数器来统计
        for (int i = 0; i < array1.length ; i++) {
            if (array1[i] >= 48 && array1[i] <= 57){//数字的ASCII码为48--57
                count++;
            }
        }
        return count;
    }
    //测试
    public static void main(String[] args) {
        String str = new String();
        str = "hahahahahaah12345";
        System.out.println("字符串中数字的个数："+isNumeric(str));
    }
}
